//
//  MainViewController.m
//  OC_WeiboApp
//
//  Created by 李旭阳 on 15/11/25.
//  Copyright © 2015年 apple. All rights reserved.
//

#import "MainViewController.h"
#import "MaintabBar.h"


@interface MainViewController ()<MaintabBarDelegate>

@end

@implementation MainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    MaintabBar *tabar = [[MaintabBar alloc] init];
    tabar.delegate = self;
    [self setValue:tabar forKey:@"tabBar"];
    UITableViewController *homeCtrl = [UITableViewController new];
    [self addChildViewCtrl:homeCtrl imageName:@"tabbar_home" title:@"首页"];
    
    UITableViewController *messageCtrl = [UITableViewController new];
    [self addChildViewCtrl:messageCtrl imageName:@"tabbar_message_center" title:@"消息"];
    
    UITableViewController *discoverCtrl = [UITableViewController new];
    [self addChildViewCtrl:discoverCtrl imageName:@"tabbar_discover" title:@"发现"];
    
    UITableViewController *profileCtrl = [UITableViewController new];
    [self addChildViewCtrl:profileCtrl imageName:@"tabbar_profile" title:@"我"];

    
}

-(void)addChildViewCtrl:(UIViewController *)ctrl imageName:(NSString *)imageName title:(NSString *)title{
    ctrl.tabBarItem.title = title;
    ctrl.tabBarItem.image = [UIImage imageNamed:imageName];
    //imageWithRenderingMode 设置图片原样显示
    ctrl.tabBarItem.selectedImage = [[UIImage imageNamed:[NSString stringWithFormat:@"%@_selected",imageName]]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    //添加tabbar
    [self addChildViewController:ctrl];
}

-(void)tabBar:(MaintabBar *)mainBar plusBtnDidClicked:(UIButton *)btn{
    NSLog(@"%s",__func__);
}


@end
